<template>
  <div class="my-param-val-maintain-table-submitform">

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="生效日期" prop="s_date">
              <el-date-picker
                v-model="formSubmitDataCom.s_date"
                type="date"
                placeholder="Please pick a date"
                value-format="yyyy-MM-dd"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="失效日期" prop="e_date">
              <el-date-picker
                v-model="formSubmitDataCom.e_date"
                type="date"
                placeholder="Please pick a date"
                value-format="yyyy-MM-dd"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- 转移曲线： -->
            <el-form-item label="转移曲线编号：" prop="cv_code">
              <el-select
                v-model="formSubmitDataCom.cv_code"
                class="filter-item"
                placeholder="Please select"
                >
                <el-option v-for="item in cvCodeOptions" :key="item.cv_code" :label="item.cv_name"
                           :value="item.cv_code"/>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <template v-if="curveDeadlineSetList">
            <template v-for="item in curveDeadlineSetList">
              <el-col :span="12" :key="item.term_code">
                <el-form-item
                  :label="item.term_name"
                  :prop="`term_${item.term_code}`"
                  :rules="[{required: true, message: '请输入值', trigger: 'blur'}]"
                >
                  <el-input-number
                    class="wb100"
                    v-model="formSubmitDataCom[`term_${item.term_code}`]"
                  ></el-input-number>
                </el-form-item>
              </el-col>

              <el-col :span="12" :key="item.term_code+'_adj_type'">
                <el-form-item
                  :label="item.term_name + '单位'"
                  :prop="`term_${item.term_code}_adj_type`"
                  :rules="[{required: true, message: '请输入值', trigger: 'blur'}]"
                >
                  <el-select
                    v-model="formSubmitDataCom[`term_${item.term_code}_adj_type`]"
                    class="filter-item"
                    placeholder="Please select"
                  >
                    <el-option v-for="item in curveDeadlineSetListUnit" :key="item.code" :label="item.name"
                               :value="item.code"/>
                  </el-select>

                  <!-- <el-input-number
                    class="wb100"
                    v-model="formSubmitDataCom[`term_${item.term_code}`]"
                  ></el-input-number> -->
                </el-form-item>
              </el-col>
            </template>
          </template>
        </el-row>




  </div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// import PageHeaderLayout from '@/layouts/PageHeaderLayout'
// import ApeDrawer from '@/components/ApeDrawer'
// import { mapGetters } from 'vuex'
// const calendarTypeOptions = [
//   { key: 'lp_code', display_name: 'lp_name' },
// ]
import * as _ from 'lodash'

export default {
  name: 'submitFormTimeLimit',
  components: {
    //PageHeaderLayout,
  },
  props: {
    // dialogFormVisible: {
    //   type: Boolean,
    //   default: false
    // },
    // dialogStatus: {
    //   type: String,
    // },
    // tableColumn: {
    //     type: Array,
    //     default() {
    //         return []
    //     }
    // },
    formSubmitData: {
      type: Object,
      default: function () {
        return {}
      }
    },
    // 法人selectData
    // lpOptions: {
    //   type: Array
    // },
    cvCodeOptions: {
      type: Array
    },
    // 曲线期限设置列表
    curveDeadlineSetList: {
      type: Array
    },
    // 曲线期限设置参数的单位
    curveDeadlineSetListUnit: {
      type: Array
    }
  },
  // 定义属性
  data() {

    return {
      textMap: {
        update: '修改',
        create: '新增'
      },
      rules: {
        s_date: [{required: true, message: '生效日期必填', trigger: 'change'}],
        e_date: [{required: true, message: '失效日期必填', trigger: 'change'}],
        // cv_code: [{required: true, message: '转移曲线编号必填', trigger: 'change'}],
        // // adj_value: [{required: true, message: '调整点差值必填', trigger: 'change'}],
        // adj_type: [{required: true, message: '调整单位必填', trigger: 'change'}],
        // type: [{ required: true, message: 'type is required', trigger: 'change' }],
        // timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
        // title: [{ required: true, message: 'title is required', trigger: 'blur' }]
      },
       /* 监听属性 watch API */
      debouncedFormSubmitData_cv_code: _.debounce(this.findTremCodeW, 500),
      // 表单用到的值
      // statusOptions: ['published', 'draft', 'deleted'],
    }
  },
  // 计算属性，会监听依赖属性值随之变化
  computed: {
    DialogFormVisibleCom: {
      get() {
        return this.dialogFormVisible
      },
      set(val) {
        this.$emit('update:dialogFormVisible', val)
      }
    },
    formSubmitDataCom: {
      get() {
        return this.formSubmitData
      },
      set(val) {
        this.$emit('update:formSubmitData', val)
      }
    },
    // 监听多个值变化-删除没有监听的元素也会触发
    // formSubmitData_findTremCode(){
    //   const {cv_code,s_date,e_date} = this.formSubmitData
    //   return {cv_code,s_date,e_date}
    // },
    // formSubmitData_findTremCode(){
    //   return {
    //       cv_code:this.formSubmitData.cv_code,
    //       s_date:this.formSubmitData.s_date,
    //       e_date:this.formSubmitData.e_date
    //     }
    // },
    formSubmitData_cv_code() {
      return this.formSubmitData.cv_code
    },
    formSubmitData_s_date() {
      return this.formSubmitData.s_date
    },
    formSubmitData_e_date() {
      return this.formSubmitData.e_date
    },
  },
  // 监控data中的数据变化
  watch: {
    // 监听多个值变化
    // formSubmitData_findTremCode(nObj,old){
    //   console.log('formSubmitData_findTremCode监听多个值变化',nObj);
    //   // console.log('formSubmitData_findTremCode监听多个值变化',old);
    //   // if (nObj.cv_code !== '' && nObj.s_date !== '' && nObj.e_date !== '') {
    //       this.findTremCodeW(nObj)
    //   // }

    // }
    // formSubmitData_cv_code(nObj, old) {
    //   this.debouncedFormSubmitData_cv_code(nObj)
    // },
    // formSubmitData_s_date(nObj, old) {
    //   this.debouncedFormSubmitData_cv_code(nObj)
    // },
    // formSubmitData_e_date(nObj, old) {
    //   this.debouncedFormSubmitData_cv_code(nObj)
    // },
    formSubmitData_cv_code: {
      handler(nObj, old){
        this.debouncedFormSubmitData_cv_code(nObj)
      },
      immediate: true
    },
    formSubmitData_s_date: {
      handler(nObj, old){
        this.debouncedFormSubmitData_cv_code(nObj)
      },
      immediate: true
    },
    formSubmitData_e_date: {
      handler(nObj, old){
        this.debouncedFormSubmitData_cv_code(nObj)
      },
      immediate: true
    },
  },
  // 方法集合
  methods: {
    findTremCodeW(nObj) {
      //第三个参数传入是修改监听还是新增监听
      this.$emit('findTremCodeWEmit', nObj)
    },








    // resetFormData() {

    //   let exclude = [
    //     'lp_code',
    //     'adj_type',
    //     'adj_name',
    //     'adj_code'
    //   ]
    //   this.$emit('resetFormDataEmit', {
    //     exclude,
    //   })
    // },
    // findlp() {
    //   this.$refs['datalp'].validate((valid) => {
    //     if (valid) {
    //       this.$emit('findlp')
    //       // this.temp.id = parseInt(Math.random() * 100) + 1024 // mock a id
    //       // this.temp.author = 'vue-element-admin'
    //       // createArticle(this.temp).then(() => {
    //       //   this.list.unshift(this.temp)
    //       //   this.dialogFormVisible = false
    //       //   this.$notify({
    //       //     title: 'Success',
    //       //     message: 'Created Successfully',
    //       //     type: 'success',
    //       //     duration: 2000
    //       //   })
    //       // })
    //     }
    //   })
    // },
    // createData() {
    //   this.$refs['dataForm'].validate((valid) => {
    //     if (valid) {
    //       this.$emit('handleFromCreateDataEmit')
    //       this.$delete(this.formSubmitData, "adj_code");
    //       this.$delete(this.formSubmitData, "adj_name");
    //       // this.$delete(this.formSubmitData, "adj_type");
    //       // this.temp.id = parseInt(Math.random() * 100) + 1024 // mock a id
    //       // this.temp.author = 'vue-element-admin'
    //       // createArticle(this.temp).then(() => {
    //       //   this.list.unshift(this.temp)
    //       //   this.dialogFormVisible = false
    //       //   this.$notify({
    //       //     title: 'Success',
    //       //     message: 'Created Successfully',
    //       //     type: 'success',
    //       //     duration: 2000
    //       //   })
    //       // })
    //     }
    //   })
    // },

    // updateData() {
    //   this.$refs['dataForm'].validate((valid) => {
    //     if (valid) {
    //       this.$delete(this.formSubmitData, "_XID");
    //       this.$delete(this.formSubmitData, "lp_name");
    //       // const tempData = Object.assign({}, this.formSubmitData)
    //       this.$emit('handleFromUpdateDataEmit')
    //       // tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
    //       // updateArticle(tempData).then(() => {
    //       //   const index = this.list.findIndex(v => v.id === this.temp.id)
    //       //   this.list.splice(index, 1, this.temp)
    //       //   this.dialogFormVisible = false
    //       //   this.$notify({
    //       //     title: 'Success',
    //       //     message: 'Update Successfully',
    //       //     type: 'success',
    //       //     duration: 2000
    //       //   })
    //       // })
    //     }
    //   })



    // },


  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  beforeCreate() {
  }, // 生命周期 - 创建之前
  beforeMount() {
  }, // 生命周期 - 挂载之前
  beforeUpdate() {
  }, // 生命周期 - 更新之前
  updated() {
  }, // 生命周期 - 更新之后
  beforeDestroy() {
  }, // 生命周期 - 销毁之前
  destroyed() {
  }, // 生命周期 - 销毁完成
  activated() {
  }, // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>

<style lang='scss' scoped>
.my-param-val-maintain-table-submitform {
  ::v-deep {
    .el-date-editor.el-input, .el-date-editor.el-input__inner {
      width: 100% !important;
    }
  }
}


</style>